﻿using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shapes;
using BrasilFramework.Controle.WPF.Comum.Validacao;

namespace BrasilFramework.Teste.ApresentacaoWPF
{
    public partial class MainWindow
    {

        public class Pessoa
        {
            public string Nome { get; set; }
            public int Idade { get; set; }
        }
        public MainWindow()
        {
            InitializeComponent();

            List<Pessoa> lista = new List<Pessoa>();

            for (int i = 0; i < 10; i++)
            {
                lista.Add(new Pessoa {Nome = "BRUNO" + i, Idade = i});
            }

            lista.Insert(0, new Pessoa { Nome = "Selecione" });

            comboBox1.ItemsSource = lista;
            //comboBox1.SelectedIndex = 0;
        }

        private void button1_Click_1(object sender, RoutedEventArgs e)
        {
            txtTeste.Filtro = TextBoxFilterService.TipoFiltro.Inteiro;
        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            txtTeste.Filtro = TextBoxFilterService.TipoFiltro.Valor;
        }

        private void button3_Click(object sender, RoutedEventArgs e)
        {
            txtTeste.Filtro = TextBoxFilterService.TipoFiltro.ValorPositivo;
        }

        private void button4_Click(object sender, RoutedEventArgs e)
        {
            //MessageBox.Show(calendario1.Validar());
        }

        private void button5_Click(object sender, RoutedEventArgs e)
        {
            string valor = Comum.Utilitario.Valida.ExtrairNumero("993.901.831-20");

            // Create a drawing of two ellipses.
            GeometryDrawing aDrawing = new GeometryDrawing();

            // Use geometries to describe two overlapping ellipses.
            EllipseGeometry ellipse1 = new EllipseGeometry {RadiusX = 20, RadiusY = 45, Center = new Point(50, 50)};
            EllipseGeometry ellipse2 = new EllipseGeometry {RadiusX = 45, RadiusY = 20, Center = new Point(50, 50)};
            GeometryGroup ellipses = new GeometryGroup();
            ellipses.Children.Add(ellipse1);
            ellipses.Children.Add(ellipse2);

            // Add the geometry to the drawing.
            aDrawing.Geometry = ellipses;

            // Specify the drawing's fill.
            aDrawing.Brush = Brushes.Blue;

            // Specify the drawing's stroke.
            Pen stroke = new Pen
                             {
                                 Thickness = 10.0,
                                 Brush = new LinearGradientBrush(
                                     Colors.Black, Colors.Gray, new Point(0, 0), new Point(1, 1))
                             };
            aDrawing.Pen = stroke;

            // Create a DrawingBrush
            DrawingBrush myDrawingBrush = new DrawingBrush {Drawing = aDrawing};

            // Create a Rectangle element.
            Rectangle aRectangle = new Rectangle
                                       {
                                           Width = 150,
                                           Height = 150,
                                           Stroke = Brushes.Black,
                                           StrokeThickness = 1.0
                                       };

            // Use the DrawingBrush to paint the rectangle's
            // background.
            rectangle1.Fill = myDrawingBrush;



        }

        private void button6_Click(object sender, RoutedEventArgs e)
        {
            Grid area = new Grid { Width = 16, Height = 16 };
            Ellipse circulo = new Ellipse { Fill = Brushes.Red };
            TextBlock texto = new TextBlock { Text = "!", Foreground = Brushes.White, FontWeight = FontWeights.Bold, HorizontalAlignment = HorizontalAlignment.Center };
            area.Children.Add(circulo);
            area.Children.Add(texto);

            VisualBrush areaDesenho = new VisualBrush(area) { Stretch = Stretch.None };
            rectangle1.Fill = areaDesenho;
        }

        private int quantidade;

        private void EventoUp(object sender, KeyEventArgs e)
        {
            quantidade += 1;
            lblResultado.Content = "EVENTO " + quantidade;
        }

        private void btnNenhum_Click(object sender, RoutedEventArgs e)
        {
            txtTeste.Filtro = TextBoxFilterService.TipoFiltro.Nenhum;
        }

        private void btnRemoverEvento_Click(object sender, RoutedEventArgs e)
        {
            txtTeste.KeyUp -= EventoUp;
        }

        private void btnAdicionarEvento_Click(object sender, RoutedEventArgs e)
        {
            txtTeste.KeyUp += EventoUp;
        }

        private void txtTeste_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            quantidade += 1;
            lblResultado.Content = "EVENTO " + quantidade;
        }

        private void btnHora_Click(object sender, RoutedEventArgs e)
        {
            txtTeste.Filtro = TextBoxFilterService.TipoFiltro.Hora;
        }
    }
}
